﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Adams.Public.Web.Areas.Membership.Controllers
{
    [Authorize]
    [EnsureSsl]
    public class ClassifiedsController : Controller
    {
        [AppendLayoutViewModel]
        public ActionResult Index()
        {
            var token = User.Identity.Name;
            var model = Adams.Public.Web.Business.Web.Areas.Membership.Classifieds.Index.PageLoad(token);
            return View(model);
        }

        [AppendLayoutViewModel]
        public ActionResult Create(int id)
        {
            var token = User.Identity.Name;
            var model = Adams.Public.Web.Business.Web.Areas.Membership.Classifieds.Create.PageLoad(token, id);
            return View(model);
        }

        public JsonResult GetCategoriesByType(string typeId)
        {
            var model = Adams.Public.Web.Business.Web.Areas.Membership.Classifieds.Create.GetCategoriesByType(typeId.ToInt());
            return Json(model);
        }

        public JsonResult Save(Adams.Public.DataTransfer.Web.Areas.Membership.Classifieds.Create.FormInput input)
        {
            input.Token = User.Identity.Name;
            var model = Adams.Public.Web.Business.Web.Areas.Membership.Classifieds.Create.Save(input);
            return Json(model);
        }

        public JsonResult Renew(Adams.Public.DataTransfer.Classifieds.RenewInput input)
        {
            input.Token = User.Identity.Name;
            var model = Business.Web.Areas.Membership.Classifieds.Index.Renew(input);
            return Json(model);
        }

        public JsonResult Remove(Adams.Public.DataTransfer.Classifieds.RemoveInput input)
        {
            input.Token = User.Identity.Name;
            var model = Business.Web.Areas.Membership.Classifieds.Index.Remove(input);
            return Json(model);
        }
    }
}